package cn.org.mrliu.ssm.util;

public enum OrderBy {
	ASC {
		@Override
		public String value() {
			return "ASC";
		}
	},
	DESC{
		@Override
		public String value() {
			return "DESC";
		}
	};
	public abstract String value();
	
	public static OrderBy getOrderBy(String value) {
		if (value==null) {
			return OrderBy.ASC;
		}
		value = value.trim().toUpperCase();
		if (value.equals(OrderBy.DESC.value())) {
			return OrderBy.DESC;
		}
		return OrderBy.ASC;
	}
	
	public static OrderBy getOrderBy(Integer ordinal) {
		if (ordinal==null) {
			return OrderBy.ASC;
		}
		if (ordinal.equals(OrderBy.DESC.ordinal())) {
			return OrderBy.DESC;
		}
		return OrderBy.ASC;
	}
	
}
